package com.lazyfish.superdir.dao;

import com.lazyfish.superdir.entity.Dir;
import org.apache.ibatis.annotations.*;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
@Mapper
@Primary
public interface DirDao {
    @Select("SELECT COUNT(*) FROM Dir")
    int getTotal();
    @Select("SELECT * FROM Dir WHERE id = #{id}")
    Dir getDir(int id);
    @Select("SELECT * FROM Dir")
    List<Dir> getDirList();
    @Insert("INSERT INTO Dir (name,intro,title1,title2,title3,collect) VALUES (#{name},#{intro},#{title1},#{title2},#{title3},#{collect})")
    int makeDir(Dir dir);
    @Update("UPDATE Dir SET collect=#{collect} WHERE id=#{id}")
    int updateDirCollection(@Param("collect") int collect,@Param("id") int id);
    @Delete("DELETE FROM Dir WHERE id=#{id}")
    int deleteDir(int id);
    @Update("UPDATE Dir SET name = #{name} ,intro = #{intro},title1 = #{title1},title2 = #{title2},title3 = #{title3},collect = #{collect} where id =#{id}")
    int modifyDir(Dir dir);
}
